package json

import (
	"encoding/json"
	"fmt"
)

// Opus 作品
type Opus struct {
	Date  string `json:"date"`
	Title string `json:"title"`
}

// Actress 女演员
type Actress struct {
	Name       string `json:"name"`
	Birthday   string `json:"birthday"`
	BirthPlace string `json:"birthplace"`
	Opus       Opus   `json:"opus"`
}

func unmarshal(ac string) *Actress {
	// JSON嵌套普通JSON
	jsonData := []byte(ac)
	var actress Actress
	err := json.Unmarshal(jsonData, &actress)
	if err != nil {
		fmt.Println("error:", err)
		return nil
	}
	return &actress
}

func marshal(ac *Actress) *string {
	b, err := json.Marshal(ac)
	if err != nil {
		fmt.Println("error:", err)
		return nil
	}
	s := string(b)
	return &s
}
